
import org.testng.annotations.Test;
import equation.AddEquation;
import equation.Exercise;
import io.Answer;
import io.Check;
import io.ExerciseFileDao;

public class MainTest {
    @Test
    public void testExerciseToFile(){
        Exercise exercise=new Exercise(10);
        exercise.generateMixExercise();
        ExerciseFileDao exerciseFileDao = new ExerciseFileDao();
        String filePath="D:\\program\\program\\Software Construction\\addition and subtraction\\calcu_04_demo\\src\\习题集.txt";
        exerciseFileDao.writeExerciseToFile(exercise,filePath);
        System.out.println("习题集导出文件成功");
    }

    @Test
    public void testStringToEquation(){
        String equationStr="10+22=";
        AddEquation equation=new AddEquation(equationStr);
        System.out.println(equation.getLeftNum());

    }

    @Test
    public void testReadExerciseFromFile(){
        System.out.println("读取文件");
        ExerciseFileDao exerciseFileDao=new ExerciseFileDao();
        Exercise exercise=exerciseFileDao.readExerciseFromFile("D:\\program\\program\\Software Construction\\addition and subtraction\\calcu_04_demo\\src\\习题集.txt");
        exercise.printExercise();

    }

    public static void main(String[] args) {
        //产生习题集
        Exercise exercise=new Exercise(5);
        exercise.generateMixExercise();
        exercise.printExercise();
        //在线联系输入答案
        Answer answer=new Answer();
        answer.scanAnswerFromKeyboard(5);
        //在线批改，显示结果
        Check check=new Check();
        check.checkAnswer(exercise,answer);
        check.printCheck();
        //显示参考答案
        exercise.printExerciseResult();

    }
}
